﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YmtSystem.CrossCutting;

namespace YmtAuth.Repository.DapperRepository
{
    class Utility
    {
        public static TResponse TryExecute<TResponse>(Func<TResponse> func, TResponse defVal = default(TResponse), int retry = 0, string desc = null)
        {
            try
            {
                return func();
            }
            catch (SqlException ex)
            {
                YmatouLoggingService.Error("TryExecute MySqlException ex {0},{1}", desc, ex);
                return defVal;
            }
            catch (Exception ex)
            {
                YmatouLoggingService.Error("TryExecute MySqlException(Exception) ex {0},{1}", desc, ex);
                return defVal;
            }
        }
    }
}
